package com.test.util;

public class PageSupport {

    private int currentPageNo = 1;  //当前页面
    private int totalCount = 0; //表的总数据条数
    private int pageSize = 0; //页面容量
    private int totalPageCount; //总页数 total/pageSize + 1

    public int getCurrentPageNo() { return currentPageNo; }

    public void setCurrentPageNo(int currentPageNo) {
        if(currentPageNo > 0){
            this.currentPageNo = currentPageNo;
        }
    }

    public int getTotalCount() { return totalCount; }

    public void setTotalCount(int totalCount) {
        if(totalCount > 0){
            this.totalCount = totalCount;
            // 设置总页数
            this.setTotalPageCountByRs();
        }
    }

    public int getPageSize() { return pageSize; }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    public int getTotalPageCount() { return totalPageCount; }

    public void setTotalPageCount(int totalPageCount) { this.totalPageCount = totalPageCount; }

    public void setTotalPageCountByRs(){
        if(this.totalCount % this.pageSize == 0){
            this.totalPageCount = this.totalCount / this.pageSize;
        }else if(this.totalCount % this.pageSize > 0){
            this.totalPageCount = this.totalCount / this.pageSize + 1;
        }else{
            this.totalPageCount = 0;
        }
    }
}
